<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    .box {
      width: 100px;
      height: 100px;
      background: red;
    }
    .active {
      color: white;
    }
  </style>
  <body>
    <div class="box">hello</div>
    <button>点击1</button>
    <button>点击2</button>
    <script>
      var ele = document.querySelector(".box");
      ele.onclick = function () {
        this.classList += "active";
      };
    </script>
  </body>
</html>
